package com.ruoyi.dormitory.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dormitory.mapper.TbDormitoryMapper;
import com.ruoyi.dormitory.domain.TbDormitory;
import com.ruoyi.dormitory.service.ITbDormitoryService;

/**
 * 宿舍Service业务层处理
 *
 * @author ruoyi
 * @date 2023-12-28
 */
@Service
public class TbDormitoryServiceImpl implements ITbDormitoryService
{
    @Autowired
    private TbDormitoryMapper tbDormitoryMapper;

    /**
     * 查询宿舍
     *
     * @param id 宿舍主键
     * @return 宿舍
     */
    @Override
    public TbDormitory selectTbDormitoryById(String id)
    {
        return tbDormitoryMapper.selectTbDormitoryById(id);
    }

    /**
     * 查询宿舍列表
     *
     * @param tbDormitory 宿舍
     * @return 宿舍
     */
    @Override
    public List<TbDormitory> selectTbDormitoryList(TbDormitory tbDormitory)
    {
        return tbDormitoryMapper.selectTbDormitoryList(tbDormitory);
    }

    /**
     * 新增宿舍
     *
     * @param tbDormitory 宿舍
     * @return 结果
     */
    @Override
    public int insertTbDormitory(TbDormitory tbDormitory)
    {
//        tbDormitory.setCreateTime(DateUtils.getNowDate());
        tbDormitory.setId(UUID.randomUUID().toString().replaceAll("-",""));
        return tbDormitoryMapper.insertTbDormitory(tbDormitory);
    }

    /**
     * 修改宿舍
     *
     * @param tbDormitory 宿舍
     * @return 结果
     */
    @Override
    public int updateTbDormitory(TbDormitory tbDormitory)
    {
        tbDormitory.setUpdateTime(DateUtils.getNowDate());
        return tbDormitoryMapper.updateTbDormitory(tbDormitory);
    }

    /**
     * 批量删除宿舍
     *
     * @param ids 需要删除的宿舍主键
     * @return 结果
     */
    @Override
    public int deleteTbDormitoryByIds(String[] ids)
    {
        return tbDormitoryMapper.deleteTbDormitoryByIds(ids);
    }

    /**
     * 删除宿舍信息
     *
     * @param id 宿舍主键
     * @return 结果
     */
    @Override
    public int deleteTbDormitoryById(String id)
    {
        return tbDormitoryMapper.deleteTbDormitoryById(id);
    }
}
